package client;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import communication.Message;


public class ClientRun {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		Gui gui=new Gui();
		
		try (Socket socket = new Socket("localhost", 12345)){
			InputStream inputStream = socket.getInputStream();
			OutputStream outputStream = socket.getOutputStream();
			
			gui.setOutput(outputStream);
			
			while(true){
				byte[] yourBytes=new byte[65536];
				inputStream.read(yourBytes);
				Message response = Message.objFromByte(yourBytes);
				if(response.getCommand()!=null)
				gui.writeResponse(response.getCommand());
				if(response.getException()!=null)
				gui.writeResponse(response.getException().toString());
			} 
        }
    }
}
    	